package dashboard.constant;

import net.sf.json.JSONArray;

public class IncomeCityConst {

	public static final JSONArray ZX_CityList = JSONArray.fromObject("['北京','上海', '天津', '广州', '深圳', '成都', '重庆', '石家庄', '济南', '青岛', '南京', '杭州', '苏州', '无锡', '合肥', '武汉', '郑州', '长沙', '福州', '厦门', '南宁', '哈尔滨', '长春', '太原', '大连', '沈阳', '东莞']");
	
	/**
	 * 城市三个产品线查询列，查询条件
	 * @param dateGroup
	 * @return
	 */
	public static String getCityProCol(String dateGroup){
		return dateGroup+",jingzhun_cash, jingzhun_cus, zhiding_cash, zhiding_cus, zhineng_cash, zhineng_cus";
	}
	
	private static final String PATTEN_CityPro = "city_name='%s' AND business_name='%s' AND stat_type='%s' GROUP BY %s";
	
	public static String getCityProCon(String dateGroup, String stat_type, String businessName, String cityName){
		return String.format(PATTEN_CityPro, cityName, businessName, stat_type, dateGroup);
	}
	
	/**
	 * 27个直销城市三个产品线 表格数据查询条件
	 * @param dateGroup
	 * @return
	 */
	private static final String CityPro_Table = "%s='%s' AND business_name='%s' AND stat_type='%s' GROUP BY city_name";
	
	public static String getCityProTableCon(String dateGroup, String stat_type, String businessName, String dateVal){
		return String.format(CityPro_Table, dateGroup,dateVal, businessName, stat_type);
	}
	
	private static final String CON_CityCmp = "city_name in('%s','%s') AND business_name='%s' AND stat_type='%s' GROUP BY city_name,%s";
	private static final String COL_CityCmp = "%s,city_name,%s_cash, %s_cus";
	/**
	 * 城市对比查询列，查询条件
	 * @param dateGroup
	 * @return
	 */
	public static String getCityCmpCol(String dateGroup, String proType){
		return String.format(COL_CityCmp, dateGroup,proType);
	}
	
	public static String getCityCmpCon(String dateGroup, String stat_type, String businessName, String city1,String city2){
		return String.format(CON_CityCmp, city1,city2, businessName, stat_type, dateGroup);
	}

	private static final String CON_CityConsume = "city_name in(%s) AND business_name='%s' AND stat_type='%s' GROUP BY city_name,%s";
	private static final String COL_CityConsume = "%s,city_name,%s, %s";
	
	public static String getCityConsumeCol(String dateGroup, String index1, String index2) {
		return String.format(COL_CityConsume, dateGroup,index1, index2);
	}

	public static String getCityConsumeCon(String dateGroup, String stat_type, String businessName, JSONArray cityArr) {
		String cityString = cityArr.toString().replace("\"", "'");
		cityString = cityString.substring(1,cityString.length()-1); //去掉 [ ]
		return String.format(CON_CityConsume,cityString,businessName,stat_type, dateGroup);
	}
	
	
}
